<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href=" Css/style.css" />
<script type="text/javascript" src=" Scripts/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src=" Scripts/menu.js"></script>
<script type="text/javascript" src=" Scripts/lrscroll_1.js"></script>
<script type="text/javascript" src=" Scripts/n_nav.js"></script>
<link rel="stylesheet" type="text/css" href=" Css/shopshow.css" />
<link rel="stylesheet" type="text/css" href=" Css/magiczoom.css" />
<script type="text/javascript" src=" Scripts/magiczoom.js"></script>
<script type="text/javascript" src=" Scripts/p_tab.js"></script>
<script type="text/javascript" src=" Scripts/shade.js"></script>
<link rel="shortcut icon" href="https://www.vmall.com/favicon.ico" />
<title>用户购物车页面</title>
</head>
<body>
	<!--Begin Header Begin-->
	<div class="soubg">
		<div class="sou">
			<!--Begin 所在收货地区 Begin-->
			<span class="s_city_b"> <span class="fl">送货至：</span> <span
				class="s_city"> <span>四川</span>
					<div class="s_city_bg">
						<div class="s_city_t"></div>
						<div class="s_city_c">
							<h2>请选择所在的收货地区</h2>
							<table border="0" class="c_tab"
								style="width: 235px; margin-top: 10px;" cellspacing="0"
								cellpadding="0">
								<tr>
									<th>A</th>
									<td class="c_h"><span>安徽</span><span>澳门</span></td>
								</tr>
								<tr>
									<th>B</th>
									<td class="c_h"><span>北京</span></td>
								</tr>
								<tr>
									<th>C</th>
									<td class="c_h"><span>重庆</span></td>
								</tr>
								<tr>
									<th>F</th>
									<td class="c_h"><span>福建</span></td>
								</tr>
								<tr>
									<th>G</th>
									<td class="c_h"><span>广东</span><span>广西</span><span>贵州</span><span>甘肃</span></td>
								</tr>
								<tr>
									<th>H</th>
									<td class="c_h"><span>河北</span><span>河南</span><span>黑龙江</span><span>海南</span><span>湖北</span><span>湖南</span></td>
								</tr>
								<tr>
									<th>J</th>
									<td class="c_h"><span>江苏</span><span>吉林</span><span>江西</span></td>
								</tr>
								<tr>
									<th>L</th>
									<td class="c_h"><span>辽宁</span></td>
								</tr>
								<tr>
									<th>N</th>
									<td class="c_h"><span>内蒙古</span><span>宁夏</span></td>
								</tr>
								<tr>
									<th>Q</th>
									<td class="c_h"><span>青海</span></td>
								</tr>
								<tr>
									<th>S</th>
									<td class="c_h"><span>上海</span><span>山东</span><span>山西</span><span
										class="c_check">四川</span><span>陕西</span></td>
								</tr>
								<tr>
									<th>T</th>
									<td class="c_h"><span>台湾</span><span>天津</span></td>
								</tr>
								<tr>
									<th>X</th>
									<td class="c_h"><span>西藏</span><span>香港</span><span>新疆</span></td>
								</tr>
								<tr>
									<th>Y</th>
									<td class="c_h"><span>云南</span></td>
								</tr>
								<tr>
									<th>Z</th>
									<td class="c_h"><span>浙江</span></td>
								</tr>
							</table>
						</div>
					</div>
			</span>
			</span>
			<!--End 所在收货地区 End-->
			<span class="fr"> <span class="fl">您好, <%
 	HttpSession s = request.getSession();
 	if (s.getAttribute("USER_SESSION") == null) {
 %> 请<a href=" login.jsp">登录</a>&nbsp; <a href="regist"
					style="color: #ff4e00;">免费注册</a>&nbsp;|&nbsp; <%
 	} else {
 %> ${USER_SESSION.u_name} <a
					href="${pageContext.request.contextPath}/logout"> <i
						class="fa fa-sign-out"></i> 退出当前账号
				</a> <%
 	}
 %><a href="#">我的订单</a>&nbsp;|
			</span> <span class="ss">
					<div class="ss_list">
						<a href="#">收藏夹</a>
						<div class="ss_list_bg">
							<div class="s_city_t"></div>
							<div class="ss_list_c">
								<ul>
									<li><a href="#">我的收藏夹</a></li>
									<li><a href="#">我的收藏夹</a></li>
								</ul>
							</div>
						</div>
					</div>
					<div class="ss_list">
						<a href="#">客户服务</a>
						<div class="ss_list_bg">
							<div class="s_city_t"></div>
							<div class="ss_list_c">
								<ul>
									<li><a href="#">客户服务</a></li>
									<li><a href="#">客户服务</a></li>
									<li><a href="#">客户服务</a></li>
								</ul>
							</div>
						</div>
					</div>
					<div class="ss_list">
						<a href="#">网站导航</a>
						<div class="ss_list_bg">
							<div class="s_city_t"></div>
							<div class="ss_list_c">
								<ul>
									<li><a href="#">网站导航</a></li>
									<li><a href="#">网站导航</a></li>
								</ul>
							</div>
						</div>
					</div>
			</span> <span class="fl">|&nbsp;关注我们：</span> <span class="s_sh"><a
					href="#" class="sh1">新浪</a><a href="#" class="sh2">微信</a></span> <span
				class="fr">|&nbsp;<a href="#">手机版&nbsp;<img
						src=" Picture/s_tel.png" align="absmiddle" /></a></span>
			</span>
		</div>
	</div>
	<div class="top">
		<div class="logo">
			<a href="../index"><img
				src=" img/logoindex.png" style="width: 200px; padding-top: 20px" /></a>
		</div>
		<div class="search">
			<form>
				<input type="text" value="" class="s_ipt" /> <input type="submit"
					value="搜索" class="s_btn" />
			</form>
		</div>
		<div class="i_car">
			<div class="car_t">
				购物车 [ <span>3</span> ]
			</div>
			<div class="car_bg">
				<!--Begin 购物车未登录 Begin-->
				<div class="un_login">
					还未登录！<a href="Login.html" style="color: #ff4e00;">马上登录</a> 查看购物车！
				</div>
				<!--End 购物车未登录 End-->
				<!--Begin 购物车已登录 Begin-->
				<ul class="cars">
					<li>
						<div class="img">
							<a href="#"><img src=" Picture/car1.jpg" width="58"
								height="58" /></a>
						</div>
						<div class="name">
							<a href="#">法颂浪漫梦境50ML 香水女士持久清新淡香 送2ML小样3只</a>
						</div>
						<div class="price">
							<font color="#ff4e00"> 399</font> X1
						</div>
					</li>
					<li>
						<div class="img">
							<a href="#"><img src=" Picture/car2.jpg" width="58"
								height="58" /></a>
						</div>
						<div class="name">
							<a href="#">香奈儿（Chanel）邂逅活力淡香水50ml</a>
						</div>
						<div class="price">
							<font color="#ff4e00"> 399</font> X1
						</div>
					</li>
					<li>
						<div class="img">
							<a href="#"><img src=" Picture/car2.jpg" width="58"
								height="58" /></a>
						</div>
						<div class="name">
							<a href="#">香奈儿（Chanel）邂逅活力淡香水50ml</a>
						</div>
						<div class="price">
							<font color="#ff4e00"> 399</font> X1
						</div>
					</li>
				</ul>
				<div class="price_sum">
					共计&nbsp; <font color="#ff4e00"> </font><span>1058</span>
				</div>
				<div class="price_a">
					<a href="#">去购物车结算</a>
				</div>
				<!--End 购物车已登录 End-->
			</div>
		</div>
	</div>
	<!--End Header End-->
	<!--Begin Menu Begin-->
	<div class="menu_bg">
		<div class="menu">
			<!--End 商品分类详情 End-->
			<ul class="menu_r">
				<c:forEach items="${as}" var="a">
					<li></li>
					<li><a href="../wk1un2_electricity_digital/${a.as_url}">${a.as_name}</a></li>
				</c:forEach>
			</ul>
			<div class="m_ad">过年送好礼 欢乐享不停！</div>
		</div>
	</div>
	<div class="i_bg">
		<div class="content mar_20">
			<img src="Picture/img2.jpg" />
		</div>

		<!--Begin 第二步：确认订单信息 Begin -->
		<div class="content mar_20">
			<div class="two_bg">
				<div class="two_t">
					<span class="fr"><a href="#">修改</a></span>商品列表
				</div>
				<table border="0" class="car_tab" style="width: 1110px;"
					cellspacing="0" cellpadding="0">
					<tr>
						<td class="car_th" width="490">商品名称</td>
						<td class="car_th" width="140">商品颜色</td>
						<td class="car_th" width="150">数量</td>
						<td class="car_th" width="130">单价</td>
					</tr>
					<c:forEach items="${getCart }" var="cart">
						
						<tr class="car_list_ss">
							<td>
							 <input id="c_pid" value="${cart.p_id }" hidden="hidden">
								<div class="c_s_img">
									<img src="${cart.p_url }" width="73" height="73" />
								</div> ${cart.p_name }
							</td>
							<td align="center">${cart.ps_color }</td>
							<td align="center">
								<div class="c_num">
									<input type="button" value="" onclick="jianUpdate1(jq(this),${cart.p_id});" class="car_btn_1" /> 
									<input type="text" value="${cart.as_number }" name="" class="car_ipt" />
									<input type="button" value="" onclick="addUpdate1(jq(this),${cart.p_id});" class="car_btn_2" />
								</div>
							</td>
							<td align="center" style="color: #ff4e00;"><input
								value="${cart.p_price }" hidden="hidden" />${cart.p_price }</td>
						</tr>
					</c:forEach>
				</table>

				<div class="two_t">
					<span class="fr"><a href="#">修改</a></span>收货地址
				</div>
				<table border="0" class="car_tab" style="width: 1110px;"
					cellspacing="0" cellpadding="0">
					<tr>
						<td class="car_th" width="80"></td>
						<td class="car_th" width="200">收货人姓名</td>
						<td class="car_th" width="370">收货电话</td>
						<td class="car_th" width="150">收货地址</td>
						<td class="car_th" width="135">邮政编码</td>
					</tr>
					<c:forEach items="${getAddress }" var="address">
					<tr>
						<td align="center"><input onclick="add_id(${address.ur_id})" type="checkbox" name="ch"   /></td>
						<td align="center" style="font-size: 14px;"><b>${address.ur_consigneename }<input id="said" value="${address.ur_id }" hidden="hidden"></b></td>
						<td align="center">${address.ur_phone }</td>
						<td>${address.ur_province } ${address.ur_city } ${address.ur_area } ${address.ur_detailsaddr }</td>
						<td align="center">${address.ur_email }</td>
					</tr>
					</c:forEach>
				</table>

				<div class="two_t">支付方式</div>
				<ul class="pay">
					<li>支付宝
						<div class="ch_img"></div>
					</li>
				</ul>

				<table border="0" style="width: 900px; margin-top: 20px;"
					cellspacing="0" cellpadding="0">
					<tr height="70">
						<td align="right"><b style="font-size: 14px;">应付款金额：￥<span
								style="font-size: 22px; color: #ff4e00;" id="totle_sub">0</span>
								</b></td>
					</tr>
					<tr height="70">
						<td align="right"  onclick="add()"><a ><img src="Picture/btn_sure.gif" /></a></td>
					</tr>
				</table>



			</div>
		</div>
		<!--End 第二步：确认订单信息 End-->


		<!--Begin Footer Begin -->
		<div class="b_btm_bg bg_color">
			<div class="b_btm">
				<table border="0"
					style="width: 210px; height: 62px; float: left; margin-left: 75px; margin-top: 30px;"
					cellspacing="0" cellpadding="0">
					<tr>
						<td width="72"><img src="Picture/b1.png" width="62"
							height="62" /></td>
						<td><h2>正品保障</h2>正品行货 放心购买</td>
					</tr>
				</table>
				<table border="0"
					style="width: 210px; height: 62px; float: left; margin-left: 75px; margin-top: 30px;"
					cellspacing="0" cellpadding="0">
					<tr>
						<td width="72"><img src="Picture/b2.png" width="62"
							height="62" /></td>
						<td><h2>满38包邮</h2>满38包邮 免运费</td>
					</tr>
				</table>
				<table border="0"
					style="width: 210px; height: 62px; float: left; margin-left: 75px; margin-top: 30px;"
					cellspacing="0" cellpadding="0">
					<tr>
						<td width="72"><img src="Picture/b3.png" width="62"
							height="62" /></td>
						<td><h2>天天低价</h2>天天低价 畅选无忧</td>
					</tr>
				</table>
				<table border="0"
					style="width: 210px; height: 62px; float: left; margin-left: 75px; margin-top: 30px;"
					cellspacing="0" cellpadding="0">
					<tr>
						<td width="72"><img src="Picture/b4.png" width="62"
							height="62" /></td>
						<td><h2>准时送达</h2>收货时间由你做主</td>
					</tr>
				</table>
			</div>
		</div>
		<div class="b_nav">
			<dl>
				<dt>
					<a href="#">新手上路</a>
				</dt>
				<dd>
					<a href="#">售后流程</a>
				</dd>
				<dd>
					<a href="#">购物流程</a>
				</dd>
				<dd>
					<a href="#">订购方式</a>
				</dd>
				<dd>
					<a href="#">隐私声明</a>
				</dd>
				<dd>
					<a href="#">推荐分享说明</a>
				</dd>
			</dl>
			<dl>
				<dt>
					<a href="#">配送与支付</a>
				</dt>
				<dd>
					<a href="#">货到付款区域</a>
				</dd>
				<dd>
					<a href="#">配送支付查询</a>
				</dd>
				<dd>
					<a href="#">支付方式说明</a>
				</dd>
			</dl>
			<dl>
				<dt>
					<a href="#">会员中心</a>
				</dt>
				<dd>
					<a href="#">资金管理</a>
				</dd>
				<dd>
					<a href="#">我的收藏</a>
				</dd>
				<dd>
					<a href="#">我的订单</a>
				</dd>
			</dl>
			<dl>
				<dt>
					<a href="#">服务保证</a>
				</dt>
				<dd>
					<a href="#">退换货原则</a>
				</dd>
				<dd>
					<a href="#">售后服务保证</a>
				</dd>
				<dd>
					<a href="#">产品质量保证</a>
				</dd>
			</dl>
			<dl>
				<dt>
					<a href="#">联系我们</a>
				</dt>
				<dd>
					<a href="#">网站故障报告</a>
				</dd>
				<dd>
					<a href="#">购物咨询</a>
				</dd>
				<dd>
					<a href="#">投诉与建议</a>
				</dd>
			</dl>
			<div class="b_tel_bg">
				<a href="#" class="b_sh1">新浪微博</a> <a href="#" class="b_sh2">腾讯微博</a>
				<p>
					服务热线：<br /> <span>400-123-4567</span>
				</p>
			</div>
			<div class="b_er">
				<div class="b_er_c">
					<img src="Picture/er.gif" width="118" height="118" />
				</div>
				<img src="Picture/ss.png" />
			</div>
		</div>
		<div class="btmbg">
			<div class="btm">
				备案/许可证编号：蜀ICP备12009302号-1-www.dingguagua.com Copyright © 2015-2018
				尤洪商城网 All Rights Reserved. 复制必究 , Technical Support: Dgg Group <br />
				<img src="Picture/b_1.gif" width="98" height="33" /><img
					src="Picture/b_2.gif" width="98" height="33" /><img
					src="Picture/b_3.gif" width="98" height="33" /><img
					src="Picture/b_4.gif" width="98" height="33" /><img
					src="Picture/b_5.gif" width="98" height="33" /><img
					src="Picture/b_6.gif" width="98" height="33" />
			</div>
		</div>
		<!--End Footer End -->
	</div>
<script type="text/javascript" src="../Front/Scripts/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
var add_ids=null;
//JavaScript Document
function add_id(s_id) {
	add_ids=s_id;
}
function add() {
	   var pros1=[];
      var car_list_ss=$('.car_list_ss');
      var all_price=$("#totle_sub").html();
      for (var i = 0; i < car_list_ss.length; i++) {
        var tds=car_list_ss.eq(i).find("td");
        var tdss1=tds[0];
        var p_id=$(tdss1).find('input').val();
        var tdss2=tds[2];
        var nums1=$(tdss2).find('.car_ipt').val();
        var tdss3=tds[3];
        var price=$(tdss3).find('input').val();
        var p2={'p_id':p_id,'num':nums1,'od_price':price};
        pros1.push(p2);
      
      }
      $.post("/wk1un2_electricity_digital/Front/OrderFormAdd", {
  		"of_address":add_ids,
  		'of_total':all_price,
  		pros:JSON.stringify(pros1)
	  	},
	  	function(data){
	  		console.log(data); //  2pm
	  		var of_id=data.data.of_id;
	  		var of_price=data.data.of_price;
	  		console.log(of_id); //  2pm
	  		console.log(of_price); //  2pm
	  		window.location.href="/wk1un2_electricity_digital/Front/OrderFormId?of_id="+of_id+"&"+"of_price="+of_price;
	  	}, "json");
	  CartProId();
}

function CartProId() {
	var s=$(".sc_ids");
	console.log(s);
	var ids=[];
	for (var i = 0; i < s.length; i++) {
		console.log(s[i].checked);
		ids.push($(s[i]).val());
	}
	console.log(ids);
	var sc_id=ids.join();
	$.post("/wk1un2_electricity_digital/Front/sCartDels",{"sc_id":sc_id},function(data){
			console.log("删除成功");
	},"json"); 
}

function addUpdate1(jia,p_id){		
	var c = jia.parent().find(".car_ipt").val();
	c=parseInt(c)+1;	
	jia.parent().find(".car_ipt").val(c);
	//ajax 
	$.post("/wk1un2_electricity_digital/front/sCartEdit", {
			"as_number": c,
			"p_id":p_id
		},
		function(data){
			console.log(data.time); //  2pm
		}, "json");
	allPrice();
}
 
function allPrice(){//计算累计总价
	  $("#totle_sub").html('');
      var car_list_ss=$('.car_list_ss');
      var all_price=0;
      for (var i = 0; i < car_list_ss.length; i++) {
        var tds=car_list_ss.eq(i).find("td");
        var tdss3=tds[3];
        var tdss2=tds[2];
        var nums1=$(tdss2).find('.car_ipt').val();
        console.log(nums1);
        var price=$(tdss3).find('input').val();//循环取出每一个商品的总价
        var sss=parseFloat(nums1)*parseFloat(price);
        all_price =parseFloat(all_price)+parseFloat(sss);//进行累加/获取到购物车所有商品的总价
      }
      $("#totle_sub").html(all_price);
    }
allPrice();
function jianUpdate1(jian,p_id){    
	var c = jian.parent().find(".car_ipt").val();
	if(c==1){    
		c=1;    
	}else{    
		c=parseInt(c)-1;    
		jian.parent().find(".car_ipt").val(c);
	}
	console.log(c);
	$.post("/wk1un2_electricity_digital/Front/sCartEdit", {
		"as_number": c,
		"p_id":p_id
	},
	function(data){
		console.log(data.time); //  2pm
	}, "json");
	allPrice();
}    

</script>
</body>
</html>